// ==UserScript==
// @name         某堂绕过防挂机机制
// @namespace    https://terrason.oschina.io/experience/
// @version      1.1.3
// @description  跳过某堂防挂机机制
// @author       Angus
// @supportURL   https://terrason.gitee.io/experience/2020/%E6%9F%90%E5%A0%82%E7%BB%95%E8%BF%87%E9%98%B2%E6%8C%82%E6%9C%BA%E6%9C%BA%E5%88%B6/
// @updateURL    https://terrason.gitee.io/experience/assets/js/skip-hxxt-on-hook-defensive.user.js
// @downloadURL  https://terrason.gitee.io/experience/assets/js/skip-hxxt-on-hook-defensive.user.js
// @match        https://*.21tb.com/els/html/courseStudyItem/courseStudyItem.learn.do*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    console.log("某堂绕过防挂机机制脚本注入");
    //阻止防挂机机制
    window.$.ajaxSetup({
        dataFilter:function(data, type){
            if(this.url.startsWith("/els/html/course/course.loadCourseSystemSeting.do")){
                const setting=JSON.parse(data);
                setting.enablePreventCheat=false;
                setting.enablePreventHang=false;
                setting.checkType=0;
                return JSON.stringify(setting);
            }
            return data;
        }
    });
    //播放完自动跳转下一个
    window.setTimeout(function(){
      const $catalog = window.$("#courseItemId");
      window.setInterval(function(){
          const $playing = $catalog.find(".cl-catalog-link.cl-catalog-playing");
          if($playing.hasClass("cl-catalog-link-done")){
              const $next=$playing.closest(".cl-catalog-item").next().find(".cl-catalog-link");
              console.log("trying to click ", $next.attr("title"));
              $next.click();
          }
      },8000);
    },5000);
})();
